#include "control.h"

unsigned char Temper_Read_Flag;	//温度读取标志位
unsigned char TMAX = 30, TMIN = 20;




unsigned char Temper_Read(void)
{
	float Temp;
	unsigned char Temper_return;
	if (1 == Temper_Read_Flag)
	{
		Temper_Read_Flag = 0;	//温度读取标志位清零
		DS18B20_ConvertT();	 	//温度转换
		Temp = DS18B20_ReadT(); 	//温度读取
		Temper_return = (unsigned char)Temp;
	}	
	return Temper_return;
}


void Temper_Jiemian_1(unsigned char temperature)
{
	yi = 12;
	er = SMG_OFF_code;
	san = SMG_OFF_code;
	si = SMG_OFF_code;
	wu = SMG_OFF_code;
	liu = SMG_OFF_code;
	qi = temperature / 10;
	ba = temperature % 10;
}

void Param_Jiemian_2(void)
{
	yi = 29;
	er = SMG_OFF_code;
	san = SMG_OFF_code;
	si = TMAX / 10;
	wu = TMAX % 10;
	liu = SMG_OFF_code;
	qi = TMIN / 10;
	ba = TMIN % 10;
}



//定时器0中断服务函数
void Timer0_Rountine(void) interrupt 1
{
	static unsigned int Key4_T0Count0;
	static unsigned int T_Read_count;

	if(++Key4_T0Count0 >= 200)
	{
		//执行操作
		uc_Key_flag = 0;
		Key4_T0Count0 = 0;	//软件复位
	}
	
	if (T_Read_count++ >= 500)	//500ms 温度读取标志位置1
	{
		T_Read_count = 0;
		Temper_Read_Flag = 1;
	}
}
